function tSeries = generateRunoffTS(param,n,t,sS)
% revision 06102008
% Tobias Siegfried

if nargin > 2
    randn('seed',sS);
end
tSeries = zeros(t.tEnd,n);
for ts = 1:n
    % Generate streamflow into domain (alpha_{i}*R_{->i})
    cpNew = zeros(t.tEnd,1);
    cpOld = cpNew;
    for t = 1:t.tEnd
        if t == 1
            temp = streamflowARM(param.muS + param.sigmaS*randn,param.muS,param.rhoS,param.sigmaS,t);
            if temp < 0 % avoid negative flows
                cpNew(t) = 0;
            else
                cpNew(t) = temp;
            end
        else
            temp = streamflowARM(cpNew(t-1),param.muS,param.rhoS,param.sigmaS,t);
            if temp < 0 % avoid negative flows
                cpNew(t) = 0;
            else
                cpNew(t) = temp;
            end
        end
    end
    tSeries(:,ts) = cpNew;
end